SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].gspEmailTemplate_SEARCH
(
@emailTemplateId int = null,
@name nvarchar(128) = null,
@template nvarchar(4000) = null,
@description nvarchar(256) = null,
@createdDate datetime = null,
@lastModifiedDate datetime = null,
@isDeleted bit = null
)
AS

SELECT
  *
FROM
  [dbo].[EmailTemplate]
WHERE
  (@emailTemplateId IS NULL OR [EmailTemplateId] = @emailTemplateId)
AND
  (@name IS NULL OR @name = '' OR [Name] LIKE @name + '%')
AND
  (@template IS NULL OR @template = '' OR [Template] LIKE @template + '%')
AND
  (@description IS NULL OR @description = '' OR [Description] LIKE @description + '%')
AND
  (@createdDate IS NULL OR [CreatedDate] = @createdDate)
AND
  (@lastModifiedDate IS NULL OR [LastModifiedDate] = @lastModifiedDate)
AND
  (@isDeleted IS NULL OR [IsDeleted] = @isDeleted)


GO
